function insertSort(array){
for(i=1, n=array.length; i<n; i++){
key = array[i];
j=i-1;
while(j > -1 && key < array[j]){
array[j+1]=array[j];
j--;
}
array[j+1]=key;
}
return array;
}